﻿using IBLL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        IBaseBLL bll;
        public UserController(IBaseBLL bll)
        {
            this.bll = bll;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> Add(UserInfo t)
        {
            try
            {
                return await bll.Add(t);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="names"></param>
        /// <param name="con"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        [HttpGet]
        public IQueryable<UserInfo> GetShow(string? names = "", int? con = null, int? end = null, bool? sex = null)
        {
            try
            {
                return bll.GetShow(names, con, end,sex);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<dynamic> login(string username, string password)
        {
            try
            {
                return await bll.login(username, password);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
